package game;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;

public class Recorde extends Scene
{
	Background background;
	String[] rank;
	Font font = LoadFonte.getFonte(0);
	FontMetrics fm;
	int centerNick = 334;
	int centerPonto = 497;
	boolean escapePressionado = true;
	
	public Recorde()
	{
		background = new Background(8);
		rank = Banco.getInstance().LerTodoBanco();
		//System.out.println("ENTROOOOU");
		Audios.getInstance().Loop(10);
	}
	
	public void update() 
	{
		if(Keyboard.getInstance().isKeyPressed(KeyEvent.VK_ESCAPE))
		{
			if(!this.escapePressionado)
				SceneManager.changeScene(0);
		}
		else
			this.escapePressionado = false;
	}

	
	public void draw(Graphics2D g2d) 
	{
		background.draw(g2d);
		
		g2d.setColor(Color.BLACK);
		g2d.setFont(font);
		fm = g2d.getFontMetrics();
		for (int i = 0; i < rank.length; i++) 
		{
			if(i%2 == 1)// e impar
			{
				g2d.drawString(rank[i], this.centerNick - fm.stringWidth(rank[i])*0.5f, 225 + ((i-1)*37));
			}
			else // e par
			{
				g2d.drawString(rank[i], this.centerPonto - fm.stringWidth(rank[i])*0.5f, 225 + (i*37));
			}
		}
	}

}
